﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WithoutStateDemo1
{
    class Lift:ILift
    {
        public Status Status
        {
            get;
            
            set;
            
        }

        public void Open()
        {
            switch (this.Status)
            {
                case Status.Opening: break;//开门状态，什么都不做
                case Status.Closing: this.OpenWithoutLogic(); this.Status = Status.Opening;
                    break;
                case Status.Running: break;
                case Status.Stopping:this.OpenWithoutLogic();this.Status = Status.Opening;
                    break;
            }
        }

        public void Close()
        {
            throw new NotImplementedException();
        }

        public void Run()
        {
            throw new NotImplementedException();
        }

        public void Stop()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 纯粹的电梯关门，不考虑业务逻辑
        /// </summary>
        private void CloseWithoutLogic()
        {
            Console.WriteLine("电梯门关闭");
        }

        private void OpenWithoutLogic()
        {
            Console.WriteLine("电梯门打开");
        }

        private void RunWithoutLogic()
        {
            Console.WriteLine("电梯运行");
        }

        private void StopWithoutLogic()
        {
            Console.WriteLine("电梯停止了");
        }
    }
}
